package com.hy.day;

/**
 * Created With IntelliJ IDEA.
 * Descriptions:1103. 分糖果 II
 * <p>
 * User:Mr.Du
 * Date:2024/6/3
 * Time:9:24
 */
public class DistributeCandies {

    public int[] distributeCandies(int candies, int num_people) {
        int[] res = new int[num_people];
        int pre = 1;
        int i = 0;
        while(candies > 0){
            res[i%num_people] += Math.min(pre, candies);
            candies -= pre;
            pre++;
            i++;
        }
        return res;
    }
}
